package animation.wlh.com.animation_demo

import android.content.Intent
import android.os.Bundle
import android.support.design.widget.FloatingActionButton
import android.support.design.widget.Snackbar
import android.support.v7.app.AppCompatActivity
import android.view.Menu
import android.view.MenuItem
import android.view.View
import android.widget.AdapterView
import android.widget.ArrayAdapter
import animation.wlh.com.animation_demo.basic.BasicAnimationAct
import animation.wlh.com.animation_demo.basic.PropertyAnimationAct
import animation.wlh.com.animation_demo.basic.VectorAnimationAct
import animation.wlh.com.animation_demo.demo.BaseDemoListAct
import kotlinx.android.synthetic.main.activity_main.*
import java.util.*

class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        setSupportActionBar(toolbar)

        val fab = findViewById(R.id.fab) as FloatingActionButton
        fab.setOnClickListener { view -> Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG).setAction("Action", null).show() }
        var menuList = ArrayList<String>();
        menuList.add("基础动画")
        menuList.add("属性动画")
        menuList.add("矢量动画")
        menuList.add("动画特效")
        list.adapter = ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, menuList);
        list.onItemClickListener = AdapterView.OnItemClickListener { adapterView, view, i, l ->
            when (i) {
                0 -> {
                    startActivity(Intent(this, BasicAnimationAct::class.java))
                }
                1 -> {
                    startActivity(Intent(this, PropertyAnimationAct::class.java))
                }
                2 -> {
                    startActivity(Intent(this, VectorAnimationAct::class.java))
                }
                3 -> {
                    startActivity(Intent(this, BaseDemoListAct::class.java))
                }
            }
        }
    }

    override fun onCreateOptionsMenu(menu: Menu): Boolean {
        // Inflate the menu; this adds items to the action bar if it is present.
        menuInflater.inflate(R.menu.menu_main, menu)
        return true
    }

    override fun onOptionsItemSelected(item: MenuItem): Boolean {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        //noinspection SimplifiableIfStatement
        if (item.itemId == R.id.action_settings) {
            return true
        }
        return super.onOptionsItemSelected(item)
    }
}
